package com.red.wine.view;

import com.red.wine.R;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

/**
 * 中心图片
 * 
 * @author yhl TODO 2013-10-11上午9:54:19 {@link description}
 */
public class Circleview extends View {

	private Bitmap mHourBitmap;

	private boolean bInitComplete = false;
	float Angel = 0.0f;
	Matrix matx = new Matrix();
	Paint paint;

	public Circleview(Context context, AttributeSet attrs) {
		super(context, attrs);
		init();
	}

	float width, height;

	public Circleview(Context context, float width, float height) {
		super(context);
		this.width = width;
		this.height = height;
		init();
	}

	public void init() {
		mHourBitmap = BitmapFactory.decodeResource(getResources(),
				R.drawable.choice_point_img);
		bInitComplete = true;

	}

	public void setRotate_degree(float degree) {
		Angel = degree;
	}

	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		if (!bInitComplete) {
			return;
		}
		matx.setTranslate(width - mHourBitmap.getWidth() / 2, height
				- mHourBitmap.getHeight() / 2);

		matx.preRotate(Angel, mHourBitmap.getWidth() / 2,
				mHourBitmap.getHeight() / 2);

		canvas.drawBitmap(mHourBitmap, matx, null);

	}

}